package net.kazed.nextaction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.kazed.nextaction.database.TaskStatus;

/**
 * Application resources.
 * @author Koert Zeilstra
 */
public class ApplicationResource {

    private Map<TaskStatus, Integer> typeNameResourceMap;
    private Map<TaskStatus, Integer> typeAbbreviationResourceMap;
    private Map<TaskStatus, Integer> typeBackgroundResourceMap;
    private List<TaskStatus> actionTypes;

    public ApplicationResource() {
        super();
        typeNameResourceMap = new HashMap<TaskStatus, Integer>();
        typeNameResourceMap.put(TaskStatus.IDEA, R.string.task_type_someday);
        typeNameResourceMap.put(TaskStatus.NEXT_ACTION, R.string.task_type_next_action);
        typeNameResourceMap.put(TaskStatus.UNPROCESSED, R.string.task_type_unprocessed);
//        typeNameResourceMap.put(TaskType.WAITING, R.string.task_type_waiting);

        typeAbbreviationResourceMap = new HashMap<TaskStatus, Integer>();
        typeAbbreviationResourceMap.put(TaskStatus.IDEA, R.string.task_type_abbr_someday);
        typeAbbreviationResourceMap.put(TaskStatus.NEXT_ACTION, R.string.task_type_abbr_next_action);
        typeAbbreviationResourceMap.put(TaskStatus.UNPROCESSED, R.string.task_type_abbr_unprocessed);
//        typeAbbreviationResourceMap.put(TaskType.WAITING, R.string.task_type_abbr_waiting);

        typeBackgroundResourceMap = new HashMap<TaskStatus, Integer>();
        typeBackgroundResourceMap.put(TaskStatus.IDEA, R.color.task_type_someday_background);
        typeBackgroundResourceMap.put(TaskStatus.NEXT_ACTION, R.color.task_type_next_action_background);
        typeBackgroundResourceMap.put(TaskStatus.UNPROCESSED, R.color.task_type_unprocessed_background);
//        typeBackgroundResourceMap.put(TaskType.WAITING, R.color.task_type_waiting_background);
    }

    /**
     * @param type Task type.
     * @return Resource id of name text of type.
     */
    public int getTaskTypeName(TaskStatus type) {
        return typeNameResourceMap.get(type);
    }

    /**
     * @param type Task type.
     * @return Resource id of abbreviation text of type.
     */
    public int getTaskTypeAbbreviation(TaskStatus type) {
        return typeAbbreviationResourceMap.get(type);
    }

    /**
     * @param type Task type.
     * @return Resource id of background color of type.
     */
    public int getTaskTypeBackground(TaskStatus type) {
        return typeBackgroundResourceMap.get(type);
    }

    /**
     * @return List of TaskTypes that are valid for action tasks.
     */
    public List<TaskStatus> getActionTypes() {
        if (actionTypes == null) {
            actionTypes = new ArrayList<TaskStatus>();
            actionTypes.add(TaskStatus.UNPROCESSED);
            actionTypes.add(TaskStatus.NEXT_ACTION);
            actionTypes.add(TaskStatus.IDEA);
        }
        return actionTypes;
    }
}
